﻿using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.TextCore.Text;
using UnityEngine.UIElements;

// [assembly: UxmlNamespacePrefix("Game.UI", "first")]
public class JudianItem:VisualElement
{
    private Label ve_judianName => this.Q<Label>(className:"judianItemName");
    private VisualElement ve_judian => this.Q<VisualElement>(className:"judianItem");
    private Label ve_lockMask=> this.Q<Label>(className:"mask");
    
    public Action<VisualElement> judianClick;
    public JudianItem()
    {
        var asset = UnityEngine.Resources.Load<VisualTreeAsset>("UI/CumstomControl/JudianItem/JudianItem");
        asset.CloneTree(this);
        this.ve_judian.RegisterCallback<ClickEvent>(ce =>
        {
            judianClick?.Invoke(this);
        });
    }

    public new class UxmlFactory : UxmlFactory<JudianItem,UxmlTraits> {}
    public new class UxmlTraits : VisualElement.UxmlTraits
    {
        UxmlStringAttributeDescription m_JudianName = new UxmlStringAttributeDescription { name = "headImg" };
        

        public override IEnumerable<UxmlChildElementDescription> uxmlChildElementsDescription
        {
            get { yield break; }
        }

        public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
        {
            base.Init(ve, bag, cc);
            ((JudianItem)ve).judianName = m_JudianName.GetValueFromBag(bag, cc);
        }
    }

    string judianName;
    bool locked;

    
    public string JudianName
    {
        get => judianName;
        set
        {
            judianName = value;
            ve_judianName.text = value;
        }
    }
    public bool Locked
    {
        get => locked;
        set
        {
            locked = value;
            //蒙版
            if (locked)
            {
                ve_lockMask.style.display = DisplayStyle.Flex;
            }
            else
            {
                ve_lockMask.style.display = DisplayStyle.None;
            }


        }
    }
    
     
}